package live.ifox.helper;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.Toast;

public class CommonHelper {
    private static final String ACTIVITY_TAG = "ifox.tag";

    public static void debug(String message) {
        Log.d(ACTIVITY_TAG, message);
    }

    public static void setClipboardText(AppCompatActivity activity, String label, String detail) {
        ClipboardManager cm = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
        cm.setPrimaryClip(ClipData.newPlainText(label, detail));
    }

    public static CharSequence getClipboardText(AppCompatActivity activity) {
        ClipboardManager cm = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
        if (!cm.hasPrimaryClip())
            return "";
        else {
            return cm.getPrimaryClip().getItemAt(0).getText().toString();
        }
    }

    public static void showMessage(AppCompatActivity activity, String message) {
        Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
    }
}
